import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 账单信息 */
export interface Bills {
          id: number; // 账单ID
          dormitoryId?: number; // 宿舍ID
          energyUsageIds?: number; // 能源账单集合包括照明，空调，水
          billDate?: string | Dayjs; // 账单日期
          totalAmount?: number; // 总金额
          balance: number; // 余额
          fee?: number; // 欠费
          dueDate?: string | Dayjs; // 截止日期
  }

// 账单 API
export const BillsApi = {
  // 查询账单分页
  getBillsPage: async (params: any) => {
    return await request.get({ url: `/dorm/bills/page`, params })
  },

  // 查询账单详情
  getBills: async (id: number) => {
    return await request.get({ url: `/dorm/bills/get?id=` + id })
  },

  // 新增账单
  createBills: async (data: Bills) => {
    return await request.post({ url: `/dorm/bills/create`, data })
  },

  // 修改账单
  updateBills: async (data: Bills) => {
    return await request.put({ url: `/dorm/bills/update`, data })
  },

  // 删除账单
  deleteBills: async (id: number) => {
    return await request.delete({ url: `/dorm/bills/delete?id=` + id })
  },

  /** 批量删除账单 */
  deleteBillsList: async (ids: number[]) => {
    return await request.delete({ url: `/dorm/bills/delete-list?ids=${ids.join(',')}` })
  },

  // 导出账单 Excel
  exportBills: async (params) => {
    return await request.download({ url: `/dorm/bills/export-excel`, params })
  },
}